/* Bfgeshka, 2021
 * Made for version 3.3.2 */

func ColByLvl ( lvl )
	? lvl < 6
		return #white
	:? lvl < 11
		return #cyan
	:
		return #yellow

func GetBuffArrFull ( str )
	var arrb = []
	var arrel = []
	var retvalue = []
	arrb = string.Split( str, "," )
	for i = 0..arrb.Count() - 1
		arrel.Clear()
		arrel = string.Split( arrb[i], ":" )
		for j = 0..arrel.Count() - 1
			retvalue.Add(arrel[j])
	return retvalue

func GetBuffArr ( str )
	var arrb = []
	var arrel = []
	var retvalue = []
	arrb.Clear()
	arrb = string.Split( str, "," )
	for i = 0..arrb.Count() - 1
		arrel.Clear()
		arrel = string.Split( arrb[i], ":" )
		retvalue.Add(string.Format( "{1}{0} {2}", arrel[0], arrel[2], arrel[3] ))
/*
	var arr = Utils.GetBuffArrFull(str)
	var retvalue = []
	for i = 0..arr.Count() - 1
		retvalue.Add(string.Format( "{1}{0} {2}", arr[i * 4 + 0], arr[i * 4 + 2], arr[i * 4 + 3] ) )
*/
	return retvalue

func BU_numsyml ( num )
	var numtmp = num
	var retvalue = 1
	? num < 0
		retvalue++
		numtmp = math.Abs(num)
	for i = 1..100
		? numtmp < 10
			return retvalue

		numtmp = numtmp / 10
		retvalue++

func BU_offsetMiddle ( str, w )
	return w / 2 - string.Size(str) / 2

func BU_offsetRight ( str, w )
	return w - string.Size(str)

func BU_foeEl ()
	var retvalue = ""
	?  foe = Vigor
		retvalue = retvalue + "❤ "
	? foe = Poison
		retvalue = retvalue + "∞ "
	? foe = Ice
		retvalue = retvalue + "❄ "
	? foe = Fire
		retvalue = retvalue + "φ "
	? foe = Aether
		retvalue = retvalue + "* "
	return retvalue

func BU_foeWeak ()
	var retvalue = ""
	?  foe = Vigor
		retvalue = retvalue + "∞ "
	? foe = Poison
		retvalue = retvalue + "❄ "
	? foe = Ice
		retvalue = retvalue + "φ "
	? foe = Fire
		retvalue = retvalue + "* "
	? foe = Aether
		retvalue = retvalue + "❤ "
	return retvalue

func GetItemRune ( item )
	var retvalue = ""
	var runeElements = ["poison", "vigor", "ice", "fire", "aether"]
	var runeElShort = ["∞", "❤", "❄", "φ", "*"]
	var arr = string.Split(item, " ", true)

	for i1 = 0..runeElements.Count() - 1
		? item = runeElements[i1]
			retvalue = runeElShort[i1]
			i1 = runeElements.Count()

	var eff = arr[arr.Count() - 1]
	? eff = shiny
		eff = arr[arr.Count() - 2]

	? string.Size(eff) < 3
		retvalue = retvalue + eff
	return retvalue

func GetItemStars ( item )
	var possibleStars = ["*max*", "*0*", "*1*", "*2*", "*3*", "*4*", "*5*", "*6*", "*7*", "*8*", "*9*"]
	var shortStars = ["☆M", "☆0", "☆1", "☆2", "☆3", "☆4", "☆5", "☆6", "☆7", "☆8", "☆9" ]
		for i1 = 0..possibleStars.Count() - 1
			? item = possibleStars[i1]
				return shortStars[i1]
	return ""

func GetItemEnchant ( item )
	var possEnchants = ["+10", "+11", "+12", "+13", "+14", "+15", "+16", "+17", "+18", "+19", "+20", "+21", "+22", "+23", "+24", "+25", "+0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8", "+9"]
		for i1 = 0..possEnchants.Count()
			? item = possEnchants[i1]
				return possEnchants[i1]
	return ""

func GetItemName ( item )
	var retvalue = ""
	var runed = true
	?  item = lost
		runed = false
		?  item = skeleton_arm
			retvalue = "Skel Arm"
		:? item = blade
			retvalue = "Blade oFG"
		:?  item = bashing
			retvalue = "ShBash"
		:
			retvalue = "???"
		return retvalue
	:? item = shield
		? item = stone shield
			runed = false
			retvalue = "ShS"
		:? item = socketed_shield
			retvalue = "Sh"
		:? item = compound
			runed = false
			retvalue = "CmpSh"
	:? item = bardiche
		runed = false
		retvalue = "Bardiche"
	:? item = wand
		retvalue = "Wand"
	:? item = staff
		? item = stone
			retvalue = "StaffS"
		:
			retvalue = "Qstaff"
	:? item = hammer
		? item = stone
			retvalue = "HamS"
		:
			retvalue = "Ham"
	:? item = crossbow
		runed = false
		? item = socketed_crossbow
			runed = true
			retvalue = "XbowRn"
		? item = heavy
			retvalue = "XbowHv"
		:? item = stone
			retvalue = "XbowS"
		:? item = repeating
			retvalue = "XbowRep"
		:
			retvalue = "Xbow"
	:? item = sword
		? item = big
			retvalue = retvalue + "B"
		? item = stone
			retvalue = retvalue + "SwdS"
		:
			retvalue = retvalue + "Swd"
	:? item = shovel
		return "Shovel"
	:? item = hatchet
		return "Hatchet"
	:? item = hook
		return "Hook"
	:? item = stone
		?  item = moondial
			return "Moondial"
		:? item = mind
			return "MindSt"
		:? item = triskelion
			return "Triskelion"
		:? item = fissure
			return "FissureSt"
		:? item = quest
			return "QuestSt"
		:? item = ouroboros
			return "Ouroboros"
		:? item = experience
			return "ExpSt"
		:? item = ki
			return "KiSt"
		:? item = star
			return "StarSt"
		:? item = sight
			return "SightSt"
		:? item = throwing
			return "ThrowingSt"
		:
			return "Unknown Stone"
	:
		return "???"

	? runed
		retvalue = retvalue + " " + GetItemRune(item)
	retvalue = retvalue + " " + GetItemStars(item)
	retvalue = retvalue + GetItemEnchant(item)
	? item = shiny
		retvalue = "§" + retvalue

	return retvalue

var StrDiv = ";"
func ArraySave ( prefkey, arr )
	var arrstr = ""
	for i = 0..arr.Count() - 1
		arrstr = arrstr + arr[i]
		? i < arr.Count() - 1
			arrstr = arrstr + StrDiv
	storage.Set( prefkey, arrstr )

func ArrayLoad ( prefkey )
	var retvalue = []
	? !storage.Has(prefkey)
		return retvalue
	var arrstr = storage.Get(prefkey)
	retvalue = string.Split( arrstr, StrDiv )
	return retvalue
